package com.jin.controller;

import com.jin.config.MessageConfig.Message;
import com.jin.mapper.WareHouseInfoMapper;
import com.jin.pojo.WareHouseInfo;
import com.jin.service.WareHouseInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "库房信息")
@RestController
@RequestMapping("/WareHouse")
@CrossOrigin
public class WareHouseInfoController {

    @Autowired
    WareHouseInfoService wareHouseInfoService;

    @ApiOperation(value = "添加库房信息")
    @PostMapping("/insertWareHouseInfo")
    public Message insertWareHouseInfo(WareHouseInfo wareHouseInfo) {
        return wareHouseInfoService.insertWareHouseInfo(wareHouseInfo)>0?Message.success("200").add(wareHouseInfo.getWareHouseId()):Message.fail("400").add("fail");
    }


    @ApiOperation(value = "删除库房信息")
    @DeleteMapping("/delWareHouse")
    public Message delWareHouse(Integer WareHouseId) {
        return wareHouseInfoService.delWareHouse(WareHouseId)>0?Message.success("200").add("success"):Message.fail("400").add("fail");
    }


    @ApiOperation(value = "修改库房信息")
    @PutMapping("/updateWareHouse")
    public Message updateWareHouse(WareHouseInfo wareHouseInfo) {
        return wareHouseInfoService.updateWareHouse(wareHouseInfo)>0?Message.success("200").add("success"):Message.fail("400").add("fail");
    }


    @ApiOperation(value = "查询库房信息")
    @GetMapping("/selectWareHouse")
    public Message selectWareHouse() {
        return Message.success("200").add(wareHouseInfoService.selectWareHouse());
    }
}
